package org.goyo.main.domain.dao.system.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.goyo.common.exception.DBException;
import org.goyo.common.utils.Pager;
import org.goyo.main.domain.dao.BaseDAO;
import org.goyo.main.domain.dao.system.ISysMenuDao;
import org.goyo.main.domain.entity.system.SysMenu;
import org.springframework.stereotype.Repository;

@Repository
public class SysMenuDaoImpl extends BaseDAO implements ISysMenuDao{
	@Override
	public List<SysMenu> findByCond(Map<String, Object> cond, Pager pager) {
		StringBuffer buf = new StringBuffer("from SysMenu where 1=1 order by seq");
		List<Object> params = getCondition(buf, cond);
		return this.findObjects(buf.toString(), pager, params.toArray());
	}
	
	public List<Object> getCondition(StringBuffer buf,Map<String, Object> cond){
		List<Object> params = new ArrayList<Object>();
		return params;
	}

	@Override
	public List<SysMenu> findBylevel(int level) throws DBException {
		String hql = "from SysMenu where level=?";
		return this.findObjects(hql, null, new Object[]{level});
	}

	@Override
	public List<SysMenu> findByParentId(String parentId) throws DBException {
		String hql = "from SysMenu where parentId=?";
		return this.findObjects(hql, null, new Object[]{parentId});
	}
}
